const mysql = require("mysql2");

// 创建mysql连接池
const pool = mysql.createPool({
	host: "localhost",
	port: 3306,
	user: "root",
	password: "200095",
	database: "test",
	connectionLimit: 5, // 最大连接数量
});

/* 
promise写法
*/

// 预处理语句
const statement = "SELECT * FROM goods  WHERE price > ? AND brand = ? ;";

const poolFn = async () => {
	try {
		const [res,fields] = await pool.promise().execute(statement, [3000, "华为"]);
		console.log(res);
	} catch (error) {
		console.log(error);
	}
};
poolFn()

